//--------------------------------------------------------------------------------------------------------
// 
// Author: Zachary Gay
// Date: 8/23/2012
// Copyright (c) 2012 Zachary Gay.  All Rights Reserved.
//
// Filename: ManaProducingAbility.m
//
//--------------------------------------------------------------------------------------------------------

#import "ManaProducingAbility.h"

#import "ManaGroup.h"
#import "ManaProducer.h"
#import "GameController.h"

@implementation ManaProducingAbility

@synthesize produceableMana, myManaProducer;

#pragma mark - Constructor

- (ManaProducingAbility *) initWithProduceableMana:(ManaGroup *)_produceableMana 
                                requiresTapping:(BOOL)_requiresTapping
{
    if (self = [super init])
    {
        self.produceableMana = _produceableMana;
        
        requiresTapping = _requiresTapping;
    }
    
    return self;
}

#pragma mark - Main

- (void) useManaAbility
{
    if (requiresTapping)
    {
        if ([self.myManaProducer isTapped])
        {
            NSLog(@"ERROR: Attempting to use mana producing ability of tapped ManaProducer that requires tapping!");
            return;
        }
        else 
        {
            [self.myManaProducer tap];
        }
    }
    
    [ManaGroup addManaFromManaGroup: self.produceableMana toManaGroup: [[GameController theGameController] manaPool]];
}

@end
